package net.hn.hnms.biz.safety.monitor.company.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import net.hn.hnms.biz.api.mine.model.GasIndicatorVo;
import net.hn.hnms.biz.api.safety.location.model.CompanyAlarmVo;
import net.hn.hnms.biz.api.safety.monitor.model.AlarmTrendVo;
import net.hn.hnms.biz.api.safety.monitor.model.CompanyNowMonitorVo;
import net.hn.hnms.biz.safety.monitor.company.service.CompanyMonitorService;
import net.hn.hnms.biz.safety.monitor.domain.vo.NowSensorAlarmVo;
import net.hn.hnms.biz.safety.monitor.service.SafetyMonitorService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.satoken.config.AutoSetContainOrgs;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 智呈物联 pan'sx
 * 2022/12/26 14:00
 * 1.0 version
 */
@RestController
@RequestMapping("company/monitor")
@Api(value = "公司端相关接口", tags = {"安全监控-公司端相关接口"})
@RequiredArgsConstructor
public class CompanyController {
    private final CompanyMonitorService companyService;
    private final SafetyMonitorService safetyMonitorService;
    @GetMapping("/nowMonitor")
    @ApiOperation("实时监测")
    @AutoSetMineCode
    public R<CompanyNowMonitorVo> nowMonitor(String companyCode){
        return R.ok(companyService.nowMonitor(companyCode));
    }
    @GetMapping("/todayAlarm")
    @ApiOperation("今日报警处置情况")
    @AutoSetMineCode
    public R<List<CompanyAlarmVo.Info>> alarm(String companyCode){
        return R.ok(companyService.todayAlarm(companyCode));
    }
    @AutoSetContainOrgs
    @GetMapping("/score")
    @ApiOperation("瓦斯安全评分")
    public R<List<GasIndicatorVo>> score(String [] containOrgs){
        return R.ok(companyService.score(containOrgs));
    }

    @ApiOperation("甲烷与co超限次数")
    @GetMapping("/alarmTrend")
    public R<AlarmTrendVo> alarmTrend(String mineCode, @ApiParam("月或周") String type){
        return R.ok(safetyMonitorService.alarmTrend(mineCode,type));
    }
    @GetMapping("/todayMonitor")
    @ApiOperation("今日超限次数")
    @AutoSetMineCode
    public R<CompanyNowMonitorVo> todayMonitor(String companyCode){
        return R.ok(companyService.todayMonitor(companyCode));
    }

    @GetMapping("/getTodayNowSensorAlarmByGasesType")
    @ApiOperation("根据气体获取当天实时传感器报警")
    @AutoSetMineCode
    public R<List<NowSensorAlarmVo>> getTodayNowSensorAlarmByGases(String companyCode,
                                                                   @ApiParam(value = "气体:环境瓦斯,一氧化碳,风速，粉尘等",required = true,defaultValue = "环境瓦斯") String gasesTypeName){
        List<NowSensorAlarmVo>  list= companyService.getTodayNowSensorAlarmByGases(companyCode,gasesTypeName);
        return R.ok(list);
    }

}
